<template>
                      <!--banner轮播-->
                    <div class="swiper-container" :ref="refName">
                        <div class="swiper-wrapper">
                            <div class="swiper-slide" v-for="bannerList in bannerList" :key="bannerList.id">
                                <img :src="bannerList.imgUrl" />
                            </div>
                        </div>
                        <!-- 如果需要分页器 -->
                        <div class="swiper-pagination"></div>

                        <!-- 如果需要导航按钮 -->
                        <div class="swiper-button-prev"></div>
                        <div class="swiper-button-next"></div>
                    </div>
</template>

<script>
import Swiper from 'swiper/js/swiper'
export default {
  name: 'SlideShow',
  props:['bannerList','refName'],
  watch:{
      bannerList:{
          immediate:true,
          handler(newVal,oldVal){
              this.$nextTick(()=>{
                 new Swiper (this.$refs[this.refName], {
                    loop: true, // 循环模式选项
                    pagination: {
                    el: '.swiper-pagination',
                    },
                    navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                    },
                })        
              })
          }
      }
  }
}
</script>

<style lang="less" scoped>

</style>
